<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        /* 
    - await语句后所有的代码全部变成异步代码

    - await只能等promise实例,其他的一概不等
  
  
//     */
        async function getData() {
            console.log("start");
            //await只能等promise实例
            await new Promise((resolve, reject) => {
                setTimeout(() => {
                    console.log("计时器");
                    //当promise内部的异步代码执行完成,我们修改promise的状态,await就能收到完成信息了
                    resolve();
                }, 1000);
            });

            console.log("等计时器后的语句");
        }

        getData();
        console.log("end");



    </script>
</body>

</html>